package com.ling.sbbyyds.interaction;

import lombok.Data;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;


@Data
@ToString
public class ResultVo extends HashMap<String, Object>{
    public ResultVo() {
        put("code", 200);
        put("success", true);
    }

    public static ResultVo fail() {
        return fail(400, "我并不知道是什么错误,我只是负责来告诉你的");
    }

    public static ResultVo fail(String msg) {
        return fail(400, msg);
    }

    public static ResultVo fail(int code, String msg) {
        ResultVo res = new ResultVo();
        res.put("code", code);
        res.put("msg", msg);
        res.put("success", false);
        return res;
    }

    public static ResultVo success(Map<String, Object> data) {
        ResultVo map = new ResultVo();
        map.putAll(data);
        return map;
    }

    public static ResultVo success(Object data) {
        ResultVo map = new ResultVo();
        map.put("data",data);
        return map;
    }

    public static ResultVo success(Object data,String msg) {
        ResultVo map = new ResultVo();
        map.put("data",data);
        map.put("msg",msg);
        return map;
    }

    public static ResultVo success() {
        return new ResultVo();
    }

    @Override
    public ResultVo put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}